﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Configuration;

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void TextBox8_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBoxName_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextBoxAddress_TextChanged(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        String ConString = ConfigurationManager.ConnectionStrings["myDBConnection"].ConnectionString;
        using (SqlConnection connection = new SqlConnection(ConString))
        {
            connection.Open();
            SqlCommand command = new SqlCommand("regNewUser", connection);
            command.CommandType = System.Data.CommandType.StoredProcedure;  

            command.Parameters.AddWithValue("@Name",TextBoxName.Text);
            command.Parameters.AddWithValue("@Nicno",TextBoxNIC.Text);
            command.Parameters.AddWithValue("@Address",TextBoxAddress.Text);
            command.Parameters.AddWithValue("@Telephone",TextBoxTele.Text);
            command.Parameters.AddWithValue("@Email",TextBoxEmail.Text);            
            command.Parameters.AddWithValue("@Password",TextBoxPasswrd.Text);
            
            command.ExecuteNonQuery();
            Response.Redirect("AfterRegistration.aspx?GottextBoxName=" + TextBoxName.Text);

            connection.Close();
        }
    }
}